﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SolverLibrary.Data_Entities;

namespace SolverLibraryTest
{
    class Program
    {
        public static SudokuBoard sudokuBoard = new SudokuBoard();
        static void Main(string[] args)
        {
            initialize();
            testDetermineSubBoard();
            testSolve();
        }

        private static void initialize()
        {
            sudokuBoard.insertRow(new int[9] { 0, 0, 5, 0, 0, 0, 4, 0, 0 }, 0);
            sudokuBoard.insertRow(new int[9] { 0, 0, 2, 1, 6, 4, 7, 0, 0 }, 1);
            sudokuBoard.insertRow(new int[9] { 0, 1, 0, 0, 9, 0, 0, 3, 0 }, 2);
            sudokuBoard.insertRow(new int[9] { 4, 0, 0, 9, 0, 2, 0, 0, 3 }, 3);
            sudokuBoard.insertRow(new int[9] { 0, 0, 9, 0, 1, 0, 2, 0, 0 }, 4);
            sudokuBoard.insertRow(new int[9] { 8, 0, 0, 6, 0, 5, 0, 0, 7 }, 5);
            sudokuBoard.insertRow(new int[9] { 0, 5, 0, 0, 7, 0, 0, 8, 0 }, 6);
            sudokuBoard.insertRow(new int[9] { 0, 0, 8, 4, 2, 6, 5, 0, 0 }, 7);
            sudokuBoard.insertRow(new int[9] { 0, 0, 7, 0, 0, 0, 3, 0, 0 }, 8);
        }

        private static void testDetermineSubBoard() {
            bool shouldBeOne = sudokuBoard.determineSubBoard(0, 0) == 1;
            bool shouldBeTwo = sudokuBoard.determineSubBoard(3, 0) == 2;
            bool shouldBeTwoAgain = sudokuBoard.determineSubBoard(0, 3) == 4;
            bool shouldBeNine = sudokuBoard.determineSubBoard(8, 8) == 9;
            bool shouldBeEight = sudokuBoard.determineSubBoard(4, 7) == 8;
            bool shouldBeSeven = sudokuBoard.determineSubBoard(2, 7) == 7;
            Console.WriteLine("Test Determine SubBoard exited with a : {0}", 
                shouldBeEight && shouldBeNine && shouldBeOne && shouldBeTwo 
                && shouldBeTwoAgain && shouldBeSeven);
        }

        private static void testSolve()
        {
            SudokuPuzzle puzzle = new SudokuPuzzle(sudokuBoard);
            Console.WriteLine(puzzle.solve());
            Console.WriteLine("Done with solver test. Press [Enter] to continue.");
            Console.ReadLine();
        }

    }
}
